﻿<UserControl x:Class="Atlanchim.Crm.Mui.Pages.Documents.PageListDocuments"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:mui="http://firstfloorsoftware.com/ModernUI"
             xmlns:lmondeilConverters="clr-namespace:Atlanchim.Crm.Mui.Pages.Documents"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="500">
    <Grid Style="{StaticResource ContentRoot}">
        <ScrollViewer>
            <StackPanel>

                <!--Entête-->
                <TextBlock Text="Devis / Contrats" Style="{StaticResource Heading2}" />

                <!--Boutons d'action-->
                <mui:ModernButton Content="Ajouter"
                                  Command="NavigationCommands.GoToPage" CommandParameter="{Binding NewEntityUrl}"
                                  IconData="{StaticResource ResourceKey=LmondeilAddButtonPath}" Foreground="{StaticResource ResourceKey=LmondeilAddButtonColor}"/>

                <!--Liste des documents-->
                <DataGrid ItemsSource="{Binding DocumentsList}" AutoGenerateColumns="False" HorizontalAlignment="Left"
                      CanUserResizeColumns="True" CanUserSortColumns="True" SelectionMode="Extended" ColumnHeaderStyle="{DynamicResource headerStyle}" >
                    <DataGrid.Columns>
                        <DataGridTemplateColumn Header="Type" IsReadOnly="True" SortMemberPath="Type" Width="Auto">
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <Button HorizontalContentAlignment="Left" Content="{Binding Type}"
                                    Command="NavigationCommands.GoToPage" CommandParameter="{Binding Converter={lmondeilConverters:DocumentToViewUrlConverter}}" 
                                        Background="{x:Null}" BorderBrush="{x:Null}" />
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                        </DataGridTemplateColumn>
                        <DataGridTemplateColumn Header="Titre" IsReadOnly="True" SortMemberPath="Titre" Width="Auto">
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <Button HorizontalContentAlignment="Left" Content="{Binding Titre}"
                                    Command="NavigationCommands.GoToPage" CommandParameter="{Binding Converter={lmondeilConverters:DocumentToViewUrlConverter}}" 
                                        Background="{x:Null}" BorderBrush="{x:Null}"/>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                        </DataGridTemplateColumn>
                        <DataGridTemplateColumn Header="Code" IsReadOnly="True" SortMemberPath="Code" Width="Auto">
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <Button HorizontalContentAlignment="Left" Content="{Binding Code}"
                                    Command="NavigationCommands.GoToPage" CommandParameter="{Binding Converter={lmondeilConverters:DocumentToViewUrlConverter}}" 
                                        Background="{x:Null}" BorderBrush="{x:Null}"/>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                        </DataGridTemplateColumn>
                        <DataGridTemplateColumn Header="Date de Création" IsReadOnly="True" SortMemberPath="DateCreatio" Width="*">
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <Button HorizontalContentAlignment="Left" Content="{Binding DateCreatio}"
                                    Command="NavigationCommands.GoToPage" CommandParameter="{Binding Converter={lmondeilConverters:DocumentToViewUrlConverter}}" 
                                        Background="{x:Null}" BorderBrush="{x:Null}"/>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                        </DataGridTemplateColumn>
                    </DataGrid.Columns>
                </DataGrid>
            </StackPanel>
        </ScrollViewer>
    </Grid>
</UserControl>
